package ar.edu.itba.it.pdc.configuration.models.filters.destinyFilters;

import ar.edu.itba.it.pdc.configuration.models.Response;
import ar.edu.itba.it.pdc.monitoring.ProxyMonitoring;

public class DestinyMediaTypeFilter extends DestinyFilter{
	
	private String mediaType;
	
	public DestinyMediaTypeFilter(String mediaType) {
		this.mediaType = mediaType;
		setApplyOnRequest(false);
		setApplyOnResponse(true);
	}
	
	@Override
	public boolean applyFilterOnResponse(Response resp) {
		return applyFilter(resp.getMediaType());
	}
	
	public boolean applyFilter(String mediaType) {
		if (!this.mediaType.equals(mediaType)) {
			return true;
		}
		ProxyMonitoring.getInstance().addContentTypeBlocks();
		return false;
	}
	
	@Override
	public String getContent() {
		return mediaType;
	}
	
	@Override
	public String getCriteria() {
		return "Media Type";
	}
}
